import 'package:firstflutterapp/xiaomage/banner.dart';
import 'package:firstflutterapp/xiaomage/gridview.dart';
import 'package:firstflutterapp/xiaomage/listview.dart';
import 'package:firstflutterapp/xiaomage/sliver.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MainWidget());
}

class MainWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
          primaryColor: Colors.blueAccent, splashColor: Colors.transparent),
      home: Scaffold(
//        appBar: AppBar(
//          title: Text('豆瓣'),
//        ),
        body: Container(
          child: SliverWidget(),
        ),
      ),
    );
  }
}

class StarWidget extends StatefulWidget {
  //最大分值
  final double maxRating;

  //分值
  final double rating;

  //数量
  final int count;

  //大小
  final double size;

  //被选中的颜色
  final Color selectedColor;

  //未选中的颜色
  final Color unSelectedColor;

  StarWidget(
      {@required this.rating,
      this.maxRating = 10,
      this.count = 5,
      this.size = 40,
      this.selectedColor = const Color(0xffff0000),
      this.unSelectedColor = const Color(0xffbbbbbb)});

  @override
  _StarWidgetState createState() => _StarWidgetState();
}

class _StarWidgetState extends State<StarWidget> {
  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Row(
          mainAxisSize: MainAxisSize.min,
          children: buildUnSelectStarList(),
        ),
        Row(
          mainAxisSize: MainAxisSize.min,
          children: buildSelectStarList(),
        ),
      ],
    );
  }

  List<Widget> buildSelectStarList() {
    return [];
  }

  List<Widget> buildUnSelectStarList() {
    return List.generate(
        widget.count,
        (index) => Icon(Icons.star_border,
            color: widget.unSelectedColor, size: widget.size));
  }
}
